#pragma once

#include "AssetPath.h"
#include "Containers/Tuple.h"
#include "Async/PackagedTask.h"

class WHENGINE_API CAssetWriter
{
public:
    CAssetWriter() = default;
    ~CAssetWriter() = default;

    //create a async task to write asset file into memory
    //@OnlyAssetHeader: if true, only write asset header(and just need InAssetFileData header part), otherwise override the whole file
    //return a packaged task, you can get the result by calling PackagedTask::ThenInMainThread
    virtual std::shared_ptr<CPackagedTask<void>>
        CreateAsyncWriteTask(const TVector<uint8_t>& InAssetFileData , const SAssetPath& InAssetPath,bool bOnlyAssetHeader); 
    
    virtual std::shared_ptr<CPackagedTask<void>>
        CreateAsyncWriteTask(const TVector<uint8_t>& InAssetFileData 
            , const CString& InPackageName
            , const CString& InAssetPathInPackage
            , const CString& InAssetName
            , bool bOnlyAssetHeader);

    //create a proper asset path in thread pool
    virtual std::shared_ptr<CPackagedTask<TTuple<  
            TOptional<CString> /*ErrorMessage*/ 
            , SAssetPath
            , CString /*Asset display name*/
            >>>
        CreateAsyncCreateAssetPathTask(
        CClass* InClass,
        const CString& InPackageName,
        const CString& InQueryFolderRelativePath
        , const CString& InAssetName
    );

};